import {
    uploadData,
    getPosition,
    getStruct,
    pushRateToList,
    readExel
} from '../batch'

module.exports = function (params) {

    let exel = getStruct(params.downloadUrl);
    let exelList = []

    console.log("批量录入了..........")

    readExel({
        lines: exel.lines,
        cols: exel.columns,
        table: exel.table,
        eachLine(arr) {

            var row = {}
            
            var nameList = ['flag',
                'name', 'age', 'insuredWay', 'renewalMethod', 'mildProbability', 
                'evGuarantee', 'evGuaranteeScore', 'evFlexible', 'evFlexibleScore', 'evService', 'evServiceScore',
                'cgStrickenInfo', 'cgMildInfo', 'dieInfo',
                'crowdSuitsInfo',  
                // 'prePurchaseServiceId', 'insuranceCategoryId', 'isurerId'
            ];

            for (let i = 0; i < nameList.length; i++) {
                arr[i]&&(row[nameList[i]] = arr[i]);
            }

            exelList.push(row);

        }
    })

    return uploadData({
        url: "bath/re-illness-insurance",
        data: exelList,
        successData: {
            code: 1
        },
        errData: {
            
        },
        token: params.token
    })
}